import { DataSource } from "typeorm";
import { Article } from "./article/entities/article.entity";
import { DocumentChunk } from "./article/entities/document-chunk.entity";
import { Chat } from "./chat/entities/chat.entity";
import { Message } from "./chat/entities/message.entity";
import { User } from "./user/entities/user.entity";

const dataSource = new DataSource({
  type: "mysql",
  host: "localhost",
  port: 3306,
  username: "root",
  password: "0JDT001AR@yyq",
  database: "ai_chat_dev", // 修改为正确的数据库名称
  entities: [Article, DocumentChunk, Chat, Message, User],
  migrations: ["src/migrations/*{.ts,.js}"],
  migrationsTableName: "typeorm_migrations",
  synchronize: true, // 开发环境使用自动同步
});

export default dataSource;
